<?php

class FollowModel extends RelationModel{
	
	public function add($commodity_id){
		$data['uid'] = Session::getLocal('id');
		$data['commodity_id'] = $commodity_id;
		$data['tiezi_num'] = $this->getTieziNum($commodity_id);
		$data['add_time'] = time();
		$data['status'] = 1;
		$model = M("BaseFollow");
		$result = $model->data($data)->add();
		return $result;
	}
	
	public function notShow($id){
		$data['is_show'] = 0;
		$result = M("BaseFollow")->where("id='$id'")->data($data)->save();
		return $result;
	}
	
	public function del($id){
		$data['status'] = 0;
		$result = M("BaseFollow")->where("id='$id'")->data($data)->save();
		return $result;
	}
	
	public function getTieziNum($commodity_id){
		$count = D("Share")->where(array("commodity_id"=>$commodity_id))->count();
		return $count;
	}
    
}
?>
